<template>
  <div v-if="Object.keys(goods).length !== 0" class="base-info">
    <h4 class="info-title">{{ goods.title }}</h4>
    <div class="info-price">
      <span class="n-price">{{ goods.newPrice }}</span>
      <span class="o-price">{{ goods.oldPrice }}</span>
      <span v-if="goods.discount" class="discount">{{ goods.discount }}</span>
    </div>
    <div class="info-other">
      <span>{{ goods.columns[0] }}</span>
      <span>{{ goods.columns[1] }}</span>
      <span>{{ goods.services[goods.services.length - 1].name }}</span>
    </div>
    <div class="info-service">
      <!-- <span class="info-service-item" v-for="index in goods.services.length-1" :key="index">
   <img v-lazy="goods.services[index-1].icon">
<span>{{goods.services[index-1].name}}</span> -->
      <span
        class="info-service-item"
        v-for="(item, index) in goods.services.slice(0, 3)"
        :key="index"
      >
        <img v-lazy="item.icon" />
        <span>{{ item.name }}</span>
      </span>
    </div>
  </div>
</template>

<script>
export default {
  name: "DetailBaseInfo",
  props: {
    goods: {
      type: Object,
      default() {
        return {};
      },
    },
  },

  mounted() {},

  methods: {},
};
</script>

<style lang="less" scoped>
.base-info {
  margin-top: 15px;

  padding: 0 8px;
  color: #999;
  border-bottom: 5px solid #f2f5f8;
  & > div {
    margin-top: 15px;
  }
}

.info-title {
  color: #222;
}

.info-price {
  .n-price {
    font-size: 24px;
    color: var(--color-high-text);
  }
  .o-price {
    font-size: 13px;
    margin-left: 5px;
    text-decoration: line-through;
  }
  .discount {
    font-size: 12px;
    padding: 2px 5px;
    color: #fff;
    background-color: var(--color-high-text);
    border-radius: 8px;
    margin-left: 5px;
    /*让元素上浮一些: 使用相对定位即可*/
    position: relative;
    top: -8px;
  }
}

.info-other {
  line-height: 30px;
  display: flex;
  justify-content: space-between;

  border-bottom: 1px solid rgba(100, 100, 100, 0.1);
}
.info-service {
  display: flex;
  justify-content: space-between;
  line-height: 60px;
  img {
    background: var(--color-high-text);
    border-radius: 50%;
    width: 14px;
    height: 14px;
  }
  span {
    font-size: 13px;
    color: #333;
  }
}
</style>
